<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NodeList 对象 length 属性</title>
</head>

<body>
    <!-- NodeList 对象 length 属性定义了节点列表中元素的数量。 -->
    <h2>JavaScript HTML DOM!</h2>

    <p>Hello World!</p>
    <p>Hello Runoob!</p>
    <p id="demo"></p>

    <script>
        var myNodelist = document.querySelectorAll("p");
        document.getElementById("demo").innerHTML = "文档包含 " + myNodelist.length + " 个段落。";
    </script>
</body>

</html>